﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace sixgod.Common.Model
{
    public class ResponseResult<T>
    {
        public StatusCode Code { get; set; }

        public T Data { get; set; }

        public string Msg { get; set; }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResponseResult<T> Success(T data,string msg = "操作成功")
        {
            return new ResponseResult<T>() { Code = StatusCode.Success, Msg = msg, Data = data };
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static ResponseResult<T> Fail(string msg = "操作失败")
        {
            return new ResponseResult<T>() { Code = StatusCode.Fail, Msg = msg };
        }

        public static ResponseResult<T> OutTime(string msg = "令牌过期")
        {
            return new ResponseResult<T>() { Code = StatusCode.OutTime, Msg = msg };
        }

        public static ResponseResult<T> NoLogin(string msg = "没有令牌")
        {
            return new ResponseResult<T>() { Code = StatusCode.NoLogin, Msg = msg };
        }
    }

    public enum StatusCode
    {
        Success = 10000,
        /// <summary>
        /// 失败、令牌错误
        /// </summary>
        Fail = 20000,
        Error = 30000,
        /// <summary>
        /// 令牌超时
        /// </summary>
        OutTime = 40003,
        /// <summary>
        /// 没有令牌
        /// </summary>
        NoLogin = 40001
    }
}
